<template>
	<view class="container">
		<myTable2 v-model="page" :count="count" @change="changePage" v-if="list.length">
			<view v-for="item,index in list" :key="'rechargeRecord' + index" class="rechargeRecordItem">
				<view class="left">
					<view class="waiting">{{ statusText[item.status] }}</view>
					<view class="time">{{ timeFormat(item.createtime, 'hh:MM yyyy/mm/dd') }}</view>
				</view>
				<view class="amount">{{ item.price }}</view>
			</view>
		</myTable2>
		<quesheng v-if="!list.length && count"></quesheng>
	</view>
</template>

<script>
	import {
		sendMessage
	} from '@/api/websocket.js'
	import {
		timeFormat
	} from '@/utils/function/index.js'
	export default {
		data() {
			return {
				count: 0,
				list: [],
				statusText: [
					this.$t('Page.user.wzf'),
					this.$t('Page.user.cg')
				],
				timeFormat,
				page: 1
			}
		},
		created() {
			this.pageInit()
		},
		methods: {
			changePage() {
				this.callMycharge()
			},
			pageInit() {
				this.callMycharge()
			},

			callMycharge() {
				const {
					MYCHARGE
				} = this.$api
				sendMessage({
					flag: MYCHARGE,
					content: {
						page: this.page
					}
				})
				uni.$once(MYCHARGE, (e) => {
					if (e?.code === 1) {
						this.count = e.data.count
						this.list = e.data.list
					}
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.container {
		height: 100%;

		.pagingBox {
			display: flex;
			justify-content: center;
			align-items: center;

			.previous {
				margin-right: 16px;
				padding: 0 12px;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.next {
				margin-left: 16px;
				padding: 0 12px;
				display: flex;
				justify-content: center;
				align-items: center;
			}
		}
	}

	.rechargeRecordItem {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 8px;
		margin-bottom: 4px;

		&:nth-child(2n-1) {
			background: #2b333b;
		}

		.left {
			display: flex;
			flex-direction: column;

			.waiting {
				font-weight: 700;
				color: #fff;
			}

			.time {
				font-size: .75rem;
				font-weight: 400;
				line-height: 1.25rem;
				letter-spacing: .03333em;
				color: #adadc2;
			}
		}

		.amount {
			color: #adadc2;
		}
	}

	.noEntries {
		height: 100%;
		margin-top: 8px;
		// text-align: center;
		color: #adadc2;
		display: flex;
		flex-direction: column;
		align-items: center;

		.iconfontText {
			line-height: initial;
		}
	}
</style>